<!--************************************************************************************************-->
<!-- < Group.php >                                                                               -->
<!-- Copyright (c) 2012-2013 San Yat-sun University School of Software                              -->
<!-- Modifier: Xiaoxin Mo                                                                 -->
<!-- Stu : 10389159                                                                                 -->
<!-- Date: 2012-12-23                                                                               -->
<!-- Destription : ���ӱ���GroupBrief������findNGroups($N)(����ǰN��Group)��findGrouplistByMaID, findGroupnamesByMaID      -->
<!--                                                                                                -->
<!-- Version : 2.1                                                                                  -->
<!--************************************************************************************************-->

<?php 
	include_once("../db/Note.php");
	class NoteManager
	{
		static $instance;
		private $note;
		
		public function __construct(){
		}
		
		public static function getInstance(){
			if (self::$instance == null)
				self::$instance = new self();
			return self::$instance;
		}
		
		public function insert($array)
		{
			$note = new Note($array);
			$note->insert();
			return true;
		}
		
		public function delete($array)
		{
			$note = new Note($array);
			$note->delete();
		}
		
		public function update($array)
		{
			$note = new Note($array);
			$note->update();
		}
		
		// =========================Tianjiao Li==============================
		public function getValueByUsername($Username)
		{
			$note= new Note(null);
			return $note->findValueByUsername($Username);
		}
		
		public function getValueByBookname($bookname)
		{
			$note = new Note(null);
			return $note->findValueByBookname($bookname);
		}
		
		/*
		public function getValueByThesisname($Thesisname)
		{
			$comment = new Comment(null);
			return $commnet->findValueByThesisname($Thesisname);
		}
		*/
		
		public function getNotelistByUsername($Username, $N)
		{
			$note = new Note(null);
			
			if ($N == null)
				$note_list = $note->findNotelistByUsername($Username);
			else
				$note_list = $note->findNNotesByUsername($Username, $N);
			
			$note_contents = $this->getNotecontents($note_list);
			
			return $note_contents;
		}
		
		public function getNotecontents($note_list)
		{
			$note_contents = array();
			while($row = mysql_fetch_array($note_list))
				$note_contents[] = $row['Content']; 
			return $note_contents;
		}
	}
?>